<template>
	<view class="uni_box home">
		<view class="content">
			<view class="mone">
				<image class="mbg" src="/static/mine/mbgs.png"></image>
				<view class="moneview">
					<view class="sehzhitwo" @click="getshezhi">
						<image class="shezhiicon" src="/static/mine/icon_sz.png"></image>
					</view>
					<view class="touview">
						<image class="tou" :src="info.avatar?info.avatar:'/static/mine/tous.png'"></image>
						<view class="ls" v-if="info.vip==1">
							<image class="icon_rz" src='/static/mine/icon_hy.png'></image>
							<text class="huitit">会员</text>
						</view>
					</view>
					<view class="nview">
						<view class="ntouone">
							<text class="name txt">{{ info.nickname }}</text>
						</view>
						<text class="hui">邀请码ID:{{info.code}}</text>
						<text class="hui" v-if="info.endtime">会员到期时间:{{info.endtime}}</text>
					</view>
					
				</view>
			</view>
			<view class="mtwo">
				<view class="kaihui" @click="kaihui">
					<image class="img_plus" src="/static/mine/img_plus.png"></image>
					<text class="plustit">开通会员</text>
					<text class="vmiao">| 享更高权益价格奖励</text>
					<image class="icon_xyb" src="/static/mine/icon_xyb.png"></image>
				</view>
				<view class="huitwo">
					<view class="zhangone" @click="iseye=!iseye">
						<text class="zyu">账户余额(元)</text>
						<!-- <image class="yan" src="/static/mine/yan.png" v-if="!iseye"></image>
						<image class="yan" src="/static/mine/yans.png" v-if="iseye"></image> -->
					</view>
					<view class="yue" @click="getyue">
						<text class="yunum">{{info.money||0}}</text>
						<image class="icon_jr" src="/static/mine/icon_jr.png"></image>
					</view>
					<view class="tiview">
						<view class="tiitem">
							<image class="icon_wh" src="/static/mine/icon_wh.png"></image>
							<text class="tishou">累计收益</text>
							<text class="tinum">{{ info.total_shouyi||0 }}</text>
							
						</view>
						<!-- <view class="tiline"></view>
						<view class="tiitem" style="padding-left: 25rpx;">
							<image class="icon_wh" src="/static/mine/icon_wh.png"></image>
							<text class="tishou">累计收费</text>
							<text class="tinum">10658.48</text>
						</view> -->
					</view>
				</view>
			</view>
			<view class="mthree">
				<!-- <text class="fugong">服务工具</text> -->
				<view class="glist">
					<view class="gitem gitemone" v-for="(item,index) in monelist" :key="index" @click="mClick(item)">
						<image class="micon" :src="item.img"></image>
						<text>{{item.name}}</text>
					</view>
				</view>
			</view>

			<view class="tuviewnew"  @click="getshowadd">
				<image class="img_dlsnew" mode="" src="/static/mine/img_banner.png"></image>
				<view class="guangview">
					<text class="gname">看广告视频  领现金奖励</text>
					<view class="cha">查看奖励</view>
				</view>
			</view>

			<view class="tuview">
				<image class="img_dls" mode="widthFix" src="/static/mine/img_dls.png" @click="getfenzhan"></image>
			</view>
			<view class="tuview">
				<image class="img_dls" mode="widthFix" src="/static/mine/img_xmfb.png" @click="getfabu"></image>
			</view>
			
			<view class="mthree">
				<!-- <text class="fugong">服务工具</text> -->
				<view class="glist">
					<view class="gitem" v-for="(item,index) in mtwolist" :key="index" @click="mClick(item)">
						<image class="micontwo" :src="item.img"></image>
						<text>{{item.name}}</text>
					</view>
				</view>
			</view>
			<!-- <view class="tuichu" @click="gettui">退出登录</view> -->
		</view>

		<!-- 兑换弹窗 -->
		<view class="yhupopview">
			<u-popup v-model="tanshow" mode="center" @close="popclose(3)" width="82%" :closeable="true" z-index="1000">
				<view class="yhpop">

					<text class="yhtit">
						请输入兑换码
					</text>
					<view class="pinput">
						<u-input v-model="card_no" type="text" :border="false" placeholder="请输入"/>
					</view>
					<view class="quxiaoview">
						<view class="popquview" @click="popclose(3)">取消</view>
						<view class="popquview quebtn" @click="popka(3)">确认</view>
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
// #ifdef APP-PLUS
const voicdeReadSdk = uni.requireNativePlugin('xlx-voice-read-module');
// #endif
	export default {
		data() {
			return {
				monelist:[
					{id:1,name:'我的报名',img:'/static/mine/mone.png'},
					{id:2,name:'订单明细',img:'/static/mine/mtwo.png'},
					{id:3,name:'拉新活动',img:'/static/mine/mthree.png'},
					{id:4,name:'邀请好友',img:'/static/mine/mfour.png'},
					// {id:5,name:'我的团队',img:'/static/mine/mfive.png'},	
					{id:12,name:'免费领福利',img:'/static/img/icon_fl.png'},
					{id:13,name:'道具商城',img:'/static/img/icon_dj.png'},
				],
				mtwolist:[
					
					{id:6,name:'佣金排行',img:'/static/mine/mnone.png'},
					// {id:7,name:'申请列表',img:'/static/mine/mntwo.png'},
					{id:8,name:'投诉反馈',img:'/static/mine/mnthree.png'},
					// {id:9,name:'抽成设置',img:'/static/mine/mnfour.png'},
					
					{id:11,name:'三方订单',img:'/static/mine/mntwo.png'},
					{id:10,name:'关于我们',img:'/static/mine/mnfive.png'},
				],
				tanshow:false,
				value:'',
				info:{},
				user:{},
				iseye:true,
				card_no:''
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.getuserinfo();
		},
		onReady() {
			console.log("加载好了")
			this.getinit()
		},
		methods: {
			async getuserinfo(){
				let res = await this.$u.api.usergetData({
				});
				this.info = res
				// this.user = res.user
			},
			mClick(item){
				let id = item.id
				if(id == 1){
					//分享
					this.navrouter("/pages_subject/twoPage/MyBaoList");
				}else if(id == 2){
					//合同下载
					this.navrouter("/pages/TPage/MyOrder?leitype=1");
				}else if(id == 3){
					//拉新
					// this.navrouter("/pages_subject/twoPage/LaXin");
					this.navrouter("/pages_subject/twoPage/AcivityList");
				}else if(id == 4){
					//邀请好友
					this.navrouter("/pages/TPage/YaoPage");
				}else if(id == 5){
					//我的团队
					this.navrouter("/pages_subject/twoPage/MyTeam");
				}else if(id == 6){
					//排行榜
					this.navrouter("/pages/TPage/PaiHang");
				}else if(id == 7){
					//申请列表
					this.navrouter("/pages_subject/twoPage/ShengList");
				}else if(id == 8){
					//投诉反馈
					this.navrouter("/pages_subject/twoPage/TouSu");
				}else if(id == 9){
					//抽成设置
					this.navrouter("/pages_subject/twoPage/ChouCheng");
				}else if(id == 10){
					//关于我们
					this.navrouter("/pages/TPage/Guanyu");
				}else if(id == 11){
					//第三方订单
					this.navrouter("/pages/TPage/ThreeOrder");
				}else if(id == 12){
					//免费领福利
					this.navrouter("/pages/TPage/NFuli");
				}else if(id == 13){
					//道具商城
					this.navrouter("/pages/TPage/NDaoju");
				}
			},
			getshezhi(){
				this.navrouter("/pages/TPage/Ziliao");
			},
			getfenzhan(){
				console.log("+++")
				this.navrouter("/pages_subject/twoPage/FenZhan");
			},
			getfenzhantwo(){
				this.navrouter("/pages/TPage/Guanggao");
			},
			kaihui(){
				this.navrouter("/pages_subject/twoPage/VIpServices");
			},
			gettui(){
				//退出登陆
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定退出登录？',
					cancelText: "取消", // 取消按钮的文字  
					confirmText: "确认", // 确认按钮的文字  
					// showCancel: false, // 是否显示取消按钮，默认为 true
					// confirmColor: '#f55850',
					// cancelColor: '#39B54A',
					success: (res) => {
					if(res.confirm) {  
						uni.clearStorageSync();
						that.$store.commit('outLogin');
						that.$u.toast('退出成功');
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/login/login'
							})
						}, 1000);
					} else {  
						console.log('cancel') //点击取消之后执行的代码
						}  
					} 
				})
			},
			getyue(){
				this.navrouter("/pages_subject/twoPage/ZhangHu");
			},
			popclose(){
				this.card_no = ''
				this.tanshow = false
			},
			async popka(){
				let res = await this.$u.api.kaexchange({
					card_no:this.card_no
				});
				this.$u.toast("操作成功");

				this.card_no = ''
				this.popclose()
				this.getuserinfo();
			},
			getfabu(){
				this.navrouter("/pages_subject/twoPage/FabuManage");
			},
			async getinit(){
				// #ifdef H5

				// #endif
				// #ifdef APP-PLUS
				let res = await this.$u.api.voicedata({
					
				});
			console.log(res)
			
				voicdeReadSdk.init({
					appId: res.appid,//'43516296',//渠道appId，从配置后台获取
					appSecret: res.appsecret,//'RxnMEW5hKcwJE8FvnFkJtYdl20xU6vL', //密钥，从配置后台获取
					debug: false
				});
				
				// #endif
				
				
			},
			 async getshowadd(){
				// #ifdef H5
				this.$u.toast('暂不支持浏览器操作');
				// #endif
				// #ifdef APP-PLUS
				console.log(voicdeReadSdk)
				let that = this
				uni.showLoading({
					title: '加载中...',
					mask: true // 是否显示遮罩
				});
				
				let res = await this.$u.api.voicedata({
					
				});
				voicdeReadSdk.loadVoiceAd({
					resourceId: res.resource_id, //必要，资源位id
					userId: res.user_id, //可选，用于服务端回调时通知接入方给哪个用户发放奖励，不走服务端回调非必要
					mediaExtra: "", //可选，额外的透传参数，仅支持单个json对象格式，不可以嵌套json对象
					nickname: "" //可选，用户昵称
				}, result => {
					console.log("result = " + JSON.stringify(result));
					switch (result.eventType) {
						//广告加载成功(注：此时只是广告加载成功，并没有展示。如需直接展示还需调用 showVoiceAd 方法)
						case "onAdLoadSuccess":
							// preEcpm 千次展现预估收益，单次展现收益需要除1000
							this.preEcpm = result.params.preEcpm;
							break;
						// 广告加载失败
						case "onAdLoadError":
							var errorCode = result.params.errorCode;
							var errorMsg = result.params.errorMsg;
							//请务必给用户展示错误信息，方便用户反馈时排查问题
							uni.showToast({
								icon: 'none',
								title: `${errorMsg}(${errorCode})`,
								duration: 2000
							});
							break;
					} 
				})
				// 延迟2秒后关闭loading
				setTimeout(function () {
					uni.hideLoading();
					that.getshowaddtwo()
				}, 1300); 
				// #endif
				// console.log(voicdeReadSdk)
				
			},
			async getshowaddtwo(){
				// #ifdef H5
				this.$u.toast('暂不支持浏览器操作');
				// #endif
				// #ifdef APP-PLUS
				
				voicdeReadSdk.showVoiceAd(result => {
					console.log("result = " + JSON.stringify(result));
					switch (result.eventType) {
						case "onAdShow":
							//语音展示完成
							break;
						case "onAdError":
							var errorCode = result.params.errorCode;
							// this.getshowadd()
							this.$u.toast('广告加载失败,请稍后重试');
							//广告展示失败
							break;
						case "onAdClose":
							console.log('关闭广告')
							// setTimeout(() => {
							// 	uni.navigateBack()
							// }, 1000);
							//广告关闭
							break;
						/**
						 * 奖励验证回调，开发者需要在此回调中做奖励的发放
						 * 多个奖励则会回调多次
						 */
						case "onRewardVerify":
							//requestId 当前曝光的请求id
							var requestId = result.params.requestId;
							// tagId 奖励唯一标识
							var tagId = result.params.tagId;
							//rewardAmount 当次广告媒体收益（单位元）
							var rewardAmount = result.params.rewardAmount;
							break;
					} 
					})
				// #endif
				// console.log(voicdeReadSdk)
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
	}
	.content{
		background-color: #F5F5F5;
		padding-bottom: 140rpx;
		.mone{
			height: 500rpx;
			position: relative;
			.mbg{
				position: absolute;
				width: 100%;
				height: 100%;
			}
			.moneview{
				position: relative;
				width: 100%;
				padding: 70rpx 30rpx 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				// #ifdef APP-PLUS
				padding-top: 100rpx;
				// #endif
				.sehzhitwo{
					margin-left: auto;
					position: absolute;
					right: 30rpx;
					top: 30rpx;
					width: 68rpx;
					height: 68rpx;
					background: rgba(255,255,255,0.5);
					border-radius: 20rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					// #ifdef APP-PLUS
					top: 80rpx;
					// #endif
					.shezhiicon{
						// width: 44rpx;
						// height: 44rpx;
						position: absolute;
						width: 100%;
						height: 100%;
					}
				}
				.touview{
					width: 130rpx;
					height: 130rpx;
					position: relative;
					display: flex;
					align-items: center;
					justify-content: center;
					.tou{
						position: absolute;
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
					.ls{
						position: absolute;
						bottom: -10rpx;
						z-index: 1;
						padding: 6rpx 12rpx;
						background: linear-gradient(-6deg, #454545, #888888);
						border-radius: 5rpx;
						display: flex;
						align-items: center;
						.icon_rz{
							width: 44rpx;
							height: 24rpx;
							margin-right: 4rpx;
						}
						text{
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 22rpx;
							color: #FFFFFF;
						}
					}
				}
				.nview{
					display: flex;
					flex: 1;
					flex-direction: column;
					margin-left: 30rpx;
					.ntouone{
						display: flex;
						flex-direction: row;
						align-items: center;
						.name{
							font-family: PingFang SC;
							font-weight: bold;
							font-size: 44rpx;
							color: #111111;
							max-width: 80%;
							display: inline-block;
						}
						.mvip{
							width: 70rpx;
							height: 40rpx;
							margin-left: 10rpx;
						}

						.sehzhi{
							margin-left: auto;
							width: 68rpx;
							height: 68rpx;
							background: rgba(255,255,255,0.5);
							border-radius: 20rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							.shezhiicon{
								width: 44rpx;
								height: 44rpx;
							}
						}
					}
					.hui{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #333333;
						display: block;
						margin-top: 15rpx;
					}
				}
			}
		}
		.mtwo{
			margin: -220rpx 30rpx 20rpx;
			position: relative;
			background: #FFFFFF;
			border-radius: 30rpx;
			// padding: 30rpx;
			.kaihui{
				background: linear-gradient(-41deg, #4CB7F0, #198AFE);
				border-radius: 30rpx 30rpx 0 0;
				height: 130rpx;
				width: 100%;
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 0 30rpx 20rpx;
				.img_plus{
					width: 40rpx;
					height: 40rpx;
					margin-right: 19rpx;
				}
				.plustit{
					font-family: Alimama ShuHeiTi;
					font-weight: bold;
					font-size: 30rpx;
					color: #FFFFFF;
					display: inline-block;
					margin-right: 40rpx;
				}
				.vmiao{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: rgba(255, 255, 255, 0.5);
				}
				.icon_xyb{
					margin-left: 7rpx;
					width: 24rpx;
					height: 24rpx;
				}
			}
			.ming{
				position: absolute;
				top: 40rpx;
				right: 0;
				width: 130rpx;
				height: 44rpx;
				background: #E6EEFD;
				border-radius: 22rpx 0rpx 0rpx 22rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				.icon_mx{
					width: 28rpx;
					height: 28rpx;
					margin-right: 14rpx;
				}
				text{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #3E65E5;
				}
			}
			.zhangone{
				display: flex;
				flex-direction: row;
				align-items: center;
				
				.zyu{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #999999;
				}
				.yan{
					margin-left: 20rpx;
					width: 30rpx;
					height: 30rpx;
				}
			}
			.huitwo{
				background: #FFFFFF;
				border-radius: 30rpx;
				position: relative;
				margin-top: -20rpx;
				padding: 30rpx;
			}
			.zhangtwo{
				margin-top: 24rpx;
				.pjia{
					font-family: Adobe Heiti Std;
					font-weight: normal;
					font-size: 28rpx;
					color: #333333;
				}
				.jianum{
					font-family: DIN;
					font-weight: bold;
					font-size: 60rpx;
					color: #333333;
					display: inline-block;
					margin-left: 5rpx;
				}
				.feieye{
					position: relative;
					top: 18rpx;
				}
			}
			.yue{
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-top: 20rpx;
				.yunum{
					font-family: DIN;
					font-weight: bold;
					font-size: 44rpx;
					color: #333333;
				}
				.icon_jr{
					margin-left: 30rpx;
					width: 24rpx;
					height: 24rpx;
				}

			}
			.tiview{
				display: flex;
				flex-direction: row;
				margin-top: 30rpx;
				align-items: center;
				.tiitem{
					width: 50%;
					display: flex;
					flex-direction: row;
					align-items: center;
					// justify-content: center;
					// height: 30rpx;
					// border-right: 1rpx solid #CCCCCC;
					.icon_wh{
						margin-right: 2rpx;
						width: 24rpx;
						height: 24rpx;
					}
					.tinum{
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
						display: inline-block;
						margin-left: 9rpx;
					}
					.tishou{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
						display: inline-block;
					}
				}
				.tiline{
					height: 30rpx;
					width: 1rpx;
					background-color: #ccc;
				}
			}
		}
		.mthree{
			padding: 30rpx 30rpx 0;
			background: #FFFFFF;
			border-radius: 30rpx;
			margin: 0 30rpx 20rpx;
			.fugong{
				font-family: Source Han Sans CN;
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
				display: block;
				margin-bottom: 40rpx;
			}
			.glist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.gitem{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					width: 25%;
					margin-bottom: 30rpx;
					.micon{
						margin-bottom: 10rpx;
						width: 68rpx;
						height: 68rpx;
					}
					.micontwo{
						margin-bottom: 10rpx;
						width: 48rpx;
						height: 48rpx;
					}
					text{
						font-weight: 500;
						font-size: 24rpx;
						color: #222222;
					}
				}
				.gitemone{
					width: 24%;
					// flex: 1;
				}
			}
		}
		.tuichu{
			margin: 40rpx 30rpx;
			height: 88rpx;
			border-radius: 20rpx;
			border: 1px solid #999999;
			display: flex;
			align-items: center;
			justify-content: center;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #666666;
		}
	}
	.tuview{
		margin: 0rpx 30rpx 20rpx;
		
		.img_dls{
			width: 100%;
			height: 140rpx;
		}
		
	}
	.tuviewnew{
		height: 200rpx;
		position: relative;
		margin: 0rpx 30rpx 20rpx;
		.img_dlsnew{
			width: 100%;
			height: 100%;
			position: absolute;

		}
		.guangview{
			position: relative;
			padding: 40rpx 50rpx;
			display: flex;
			flex-direction: column;
			.cha{
				width: 150rpx;
				height: 44rpx;
				background: #DB413E;
				border-radius: 6rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #FFFFFF;
			}
			.gname{
				font-weight: 800;
				font-size: 40rpx;
				color: #B31312;
				display: block;
				margin-bottom: 20rpx;
			}
		}
	}
	.yhupopview{
		/deep/.u-mode-center-box{
			background-color: transparent;
		}
		.yhpop{
			border-radius: 24rpx;
			padding: 40rpx;
			background-color: #fff;
			.yhtit{
				display: block;
				text-align: center;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
				margin-bottom: 45rpx;
			}
			.pinput{
				background: #F5F5F5;
				border-radius: 10rpx;
				padding:10rpx 20rpx;
				margin-bottom: 20rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
			}
			.huoqu{
				margin-left: 20rpx;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #496EE7;
			}
			.quxiaoview{
				display: flex;
				flex-direction: row;
				margin-top: 40rpx;
				justify-content: space-between;
				width: 100%;
				.popquview{
					height: 68rpx;
					border-radius: 10rpx;
					border: 1rpx solid #111111;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 48%;
				}
				.quebtn{
					background: #496EE7;
					color: #fff;
					border: 1rpx solid #496EE7;
				}
			}
		}
	}
</style>
